package model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import util.datebase.ConexionDB;
import entidad.Area;

public class AreaModel {
	
	
	//lista de area
	public ArrayList<Area> listaArea() {
		ArrayList<Area> data = new ArrayList<Area>();
		Area bean = null;
		Connection conn = null;
		PreparedStatement pstm = null;
		try {
			conn = new ConexionDB().getConexion();
			String sql = "select * from area";
			pstm = conn.prepareStatement(sql);
			ResultSet rs = pstm.executeQuery();

			while (rs.next()) {
				bean = new Area();
				bean.setIdArea(rs.getString("idArea"));
				bean.setDescripcionArea(rs.getString("descripcionArea"));
				bean.setUbicacionArea(rs.getString("ubicacionArea"));
				bean.setPisoArea(rs.getInt("pisoArea"));
				data.add(bean);
			}
		} catch (Exception e) {
			System.out.println(e);
		} finally {
			try {
				if (pstm != null)
					pstm.close();
				if (conn != null)
					conn.close();
			} catch (SQLException e2) {
				System.out.println(e2);
			}
		}
		return data;

	}
	

}
